#include <iostream>
#include <thread>
#include <chrono>

void print_message(const std::string &message, int delay)
{
    // 1、线程内阻塞
    std::this_thread::sleep_for(std::chrono::milliseconds(delay));
    std::cout << message << std::endl;
}

int main()
{
    // 创建两个线程，执行 print_message 函数
    std::thread t1(print_message, "Hello from thread 1", 1000);
    std::thread t2(print_message, "Hello from thread 2", 500);
    t1.join();
    t2.join();
    std::cout << "Main thread finished." << std::endl;
    return 0;
}